package edu.guet.trafficforecastsystem.controller;

import edu.guet.trafficforecastsystem.model.User;
import edu.guet.trafficforecastsystem.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by yuliangwang on 2017/5/12.
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    @Qualifier("userService")
    private UserService userSerivce;

    @RequestMapping(method = RequestMethod.GET, value = "/getuser")
    public User getUser(@RequestParam(value = "userName", required = false) String userName) {
        User user = userSerivce.queryUserByName(userName);
        return user;
    }

/*    @RequestMapping(method = RequestMethod.GET, value = "/adduser")
    public String addUser(@RequestParam(value = "userName", required = false) String userName, @RequestParam("pwd") String pwd) {
        int rowsAffected = userSerivce.addUserUsingTransactional(userName, pwd);
        if (rowsAffected == 1)
            return "Add Success!";
        else
            return "Add Fail!";
    }*/
}
